//
//  WBNavigationViewController.swift
//  SinaWeibo
//
//  Created by 张晗 on 2017/1/26.
//  Copyright © 2017年 zhanghan. All rights reserved.
//

import UIKit

class WBNavigationViewController: UINavigationController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        navigationBar.isHidden = true
    }
    
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        if childViewControllers.count > 0 {
            viewController.hidesBottomBarWhenPushed = true
            if let vc = viewController as? WBBaseViewController {
                let batItem = UIBarButtonItem(title: childViewControllers.first?.title ?? "返回", target: self, action: #selector(goBack), isBack: true)
                vc.customNavItem.leftBarButtonItem = batItem
            }
        }
        super.pushViewController(viewController, animated: animated)
    }
    
    @objc fileprivate func goBack() {
       popViewController(animated: true)
    }
}
